package com.skin.common.filter;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;

import org.springframework.util.AntPathMatcher;


public class FilterMapSingleton {
	private static Map<String, String> UsercenterfilterChainDefinitionMap = new LinkedHashMap<String, String>();
	private static FilterMapSingleton mFilterMapSingleton = new FilterMapSingleton();
	private FilterMapSingleton()
	{
		//cas验证登录
		UsercenterfilterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
		// 配置不会被拦截的链接 顺序判断
		UsercenterfilterChainDefinitionMap.put("/sys/getCheckCode", "anon"); //登录验证码接口排除
		UsercenterfilterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
		UsercenterfilterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
		UsercenterfilterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
		UsercenterfilterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
		UsercenterfilterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
		UsercenterfilterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
		UsercenterfilterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录		
		UsercenterfilterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
		UsercenterfilterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
		UsercenterfilterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
		UsercenterfilterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
		UsercenterfilterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
		UsercenterfilterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
		UsercenterfilterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
		//UsercenterUsercenterfilterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
		//UsercenterUsercenterfilterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
		UsercenterfilterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
		UsercenterfilterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
		UsercenterfilterChainDefinitionMap.put("/", "anon");
		UsercenterfilterChainDefinitionMap.put("/doc.html", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.js", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.css", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.html", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.svg", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.pdf", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.jpg", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.png", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.ico", "anon");
		//update-begin--Author:sunjianlei Date:20190813 for：排除字体格式的后缀
		UsercenterfilterChainDefinitionMap.put("/**/*.ttf", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.woff", "anon");
		UsercenterfilterChainDefinitionMap.put("/**/*.woff2", "anon");
		//update-begin--Author:sunjianlei Date:20190813 for：排除字体格式的后缀
		UsercenterfilterChainDefinitionMap.put("/druid/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/swagger-ui.html", "anon");
		UsercenterfilterChainDefinitionMap.put("/swagger**/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/webjars/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/v2/**", "anon");
		//性能监控
		UsercenterfilterChainDefinitionMap.put("/actuator/metrics/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/actuator/redis/**", "anon");
		//测试示例
		UsercenterfilterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
		UsercenterfilterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
		//排除Online请求
		UsercenterfilterChainDefinitionMap.put("/auto/cgform/**", "anon");
		//websocket排除
		UsercenterfilterChainDefinitionMap.put("/websocket/**", "anon");
		//大屏设计器排除
		UsercenterfilterChainDefinitionMap.put("/big/screen/**", "anon");
		UsercenterfilterChainDefinitionMap.put("/**", "jwt");
	}
	public Map<String, String> GetUsercenterfilterChainDefinitionMap() {
		return UsercenterfilterChainDefinitionMap;
	}
	/**
	 * 
	 * @Title: IsAuthUserCenterFilter   
	 * @Description: 是否匹配到不需要鉴定权的路径   
	 * @param: @param Url
	 * @param: @return      
	 * @return: boolean      
	 * @throws
	 */
	public boolean IsAuthUserCenterFilter(String Url) {
		for(Entry<String, String> aFilterMap:UsercenterfilterChainDefinitionMap.entrySet())
		{
			AntPathMatcher matcher = new AntPathMatcher();
			if(matcher.match(aFilterMap.getKey(), Url))
			{
				return true;
			}
		}
		return false;
	}
	public static FilterMapSingleton getInstance(){
        return mFilterMapSingleton;
    }
}
